package zwo.controller;

import zwo.dao.AdminMapper;
import zwo.model.Admin;
import zwo.model.dto.AdminDTO;
import zwo.service.AdminService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/admin")
public class AdminController {
    @Resource
    private AdminMapper adminMapper;

    @Resource
    private AdminService adminService;

    @ResponseBody
    @RequestMapping("/adminLogin.do")
    public Map adminLogin(Admin admin) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("data", adminMapper.adminLogin(admin));
        return map;
    }

    @ResponseBody
    @RequestMapping("/adminAdd.do")
    public Integer adminAdd(Admin admin) {
        return adminService.adminAdd(admin);
    }

    @ResponseBody
    @RequestMapping("/adminEdit.do")
    public Integer adminEdit(Admin admin) {
        return adminMapper.adminEdit(admin);
    }

    @ResponseBody
    @RequestMapping("/adminEditPass.do")
    public Integer adminEditPass(AdminDTO adminDTO) {
        return adminService.adminEditPass(adminDTO);
    }

}
